import request from "@/libs/request";

const basePath = '/appcloud-data' ;

export const apiUrls = {
	deleteInst : basePath + '/api/appInst/delete/',
	getActiveInst : basePath + '/api/appInst/getActiveInst',
	getActiveIp : basePath + '/api/appInst/getActiveIp',
	getAppInstById : basePath + '/api/appInst/getAppInstById/',
	getAppInstList : basePath + '/api/appInst/getAppInstList',
	getScussInstByTemplateId : basePath + '/api/appInst/getInstByTemplateId/',
	getInstConfig : basePath + '/api/appInst/getInstConfig/',
	getInstCount : basePath + '/api/appInst/getInstCount',
	getInstInfoByIp : basePath + '/api/appInst/getInstInfoByIp',
	getInstNameList : basePath + '/api/appInst/getInstNameList',
	getInstStatus : basePath + '/api/appInst/getInstStatus',
	instDeployCounts : basePath + '/api/appInst/instDeployCounts/',
	saveInst : basePath + '/api/appInst/save',
	saveHostInfo : basePath + '/api/appInst/saveAppInstHosts',
	updateInst : basePath + '/api/appInst/update',
}


//根据实例id删除应用实例
export async function deleteInst(id){
	return request( apiUrls.deleteInst + id, {
      method:'GET',
  })
}
// 根据模板id及hosts查询发布的实例(成功、停止、部署中)
export async function getActiveInst(params){
	return request( apiUrls.getActiveInst, {
      method:'POST',
      body:params
  })
}

// 查询发布实例可用的ip信息
export async function getActiveIp(params){
	return request( apiUrls.getActiveIp, {
      method:'POST',
      body:params
  })
}


// 根据实例id获取应用实例
export async function getAppInstById(id){
	return request( apiUrls.getAppInstById + id, {
      method:'GET',
  })
}
// 根据条件查询应用实例列表信息
export async function getAppInstList(params){
	return request( apiUrls.getAppInstList, {
      method:'POST',
      body:params
  })
}
// 根据模板id查询发布成功的实例
export async function getScussInstByTemplateId(params){
	return request( apiUrls.getScussInstByTemplateId + params.templateId, {
      method:'GET',
  })
}
// 根据实例id查询实例配置信息
export async function getInstConfig(id){
	return request( apiUrls.getInstConfig + id, {
      method:'GET',
  })
}
// 根据ip查询部署的实例数
export async function getInstCount(params){
	return request( apiUrls.getInstCount, {
      method:'POST',
      body:params
  })
}
// (分页)根据IP查询部署的实例详情
export async function getInstInfoByIp(params){
	return request( apiUrls.getInstInfoByIp, {
      method:'POST',
      body:params
  })
}
// 根据容器Id查询实例名称
export async function getInstNameList(params){
	return request( apiUrls.getInstNameList, {
      method:'POST',
      body:params
  })
}
// 批量查询实例状态
export async function getInstStatus(params){
	return request( apiUrls.getInstStatus, {
      method:'POST',
      body:params
  })
}
// 实例部署历史统计
export async function instDeployCounts(date){
	return request( apiUrls.instDeployCounts + date, {
      method:'GET',
  })
}
// 保存应用实例
export async function saveInst(params){
	return request( apiUrls.saveInst, {
      method:'POST',
      body:params
  })
}
// 保存实例管理的hosts信息
export async function saveHostInfo(params){
	return request( apiUrls.saveHostInfo, {
      method:'POST',
      body:params
  })
}
// 更新应用实例
export async function updateInst(params){
	return request( apiUrls.updateInst, {
      method:'POST',
      body:params
  })
}